package com.idealighter.game.games.orderma.struct;

import com.idealighter.game.games.orderma.dto.PlayerBillInfo;
import com.idealighter.game.games.orderma.dto.PlayerBillItemInfo;

import java.util.HashMap;
import java.util.Map;
import java.util.Map.Entry;


/**
 * 血战到底玩家结算 .
 * 
 * @date 2016年9月27日 下午6:05:56
 *
 */
public class OderMaPlayerBill {
  // 座位顺序
  public int order;
  // 玩家名称
  public String playerName;
  // 类型(0:胡牌,1:有听,2:无听,3:花猪,4:逃跑)
  public int type;
  // 结算金币
  public long golds;
  // 被结算金币的玩家
  public Map<String, Long> billedPlayer = new HashMap<>();

  /**
   * 构造函数 .
   * 
   * @param order .
   * @param playerName .
   * @param type .
   * @param golds .
   */
  public OderMaPlayerBill(int order, String playerName, int type, long golds) {
    super();
    this.order = order;
    this.playerName = playerName;
    this.type = type;
    this.golds = golds;
  }

  /**
   * .
   * 
   * @return
   */
  public PlayerBillInfo toPlayerBillInfo() {
    PlayerBillInfo billInfo = new PlayerBillInfo();
    billInfo.setOrder(order);
    billInfo.setPlayerName(playerName);
    billInfo.setType(type);
    billInfo.setGolds(golds);
    for (Entry<String, Long> etr : billedPlayer.entrySet()) {
      PlayerBillItemInfo billItemInfo = new PlayerBillItemInfo();
      billItemInfo.setPlayerName(etr.getKey());
      billItemInfo.setGold(etr.getValue());
      billInfo.getItems().add(billItemInfo);
    }

    return billInfo;
  }
}
